package cn.rengy.web.framework.sys.menu.web;

import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresRoles;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.rengy.lang.ResultEntity;
import cn.rengy.web.framework.sys.menu.service.MenuService;


/**
 * 
 * 
 * 
 */
@Controller
@RequestMapping(value = "/authenticated/menu")
public class MenuController {
	private static Logger logger = LoggerFactory.getLogger(MenuController.class);
	@Autowired
	private MenuService menuService;
	
	@RequiresRoles(value={"developer"})
	@RequestMapping(value="/update",method = RequestMethod.POST)
	@ResponseBody
	public ResultEntity<?> update (@RequestBody Map<String,Object> paramMap){
		menuService.update(paramMap);
		return ResultEntity.ok();
	}
	
	@RequiresRoles(value={"developer"})
	@RequestMapping(value="/{id}",method = RequestMethod.DELETE)
	@ResponseBody
	public ResultEntity<?> delete(@PathVariable("id") String id){
		menuService.deleteMenu(id);
		return ResultEntity.ok();
	}
	/**
	 * 菜单查询
	 * @return
	 */
	@RequestMapping(value="/query",method = RequestMethod.POST)
	@ResponseBody
	public ResultEntity<?> menu(){
		return ResultEntity.ok(this.menuService.query());
	}
}
